﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using ProgramMain.Google;

namespace ProgramMain.OpticNet
{
    public partial class FrmCableTunnels : ProgramMain.Framework.frmBase
    {
        public FrmCableTunnels()
        {
            InitializeComponent();

            UniqueIdent = GenerateFormIdent();
        }

        private static string GenerateFormIdent()
        {
            return GenerateUniqueIdent(MethodInfo.GetCurrentMethod().DeclaringType.Name);
        }

        public static FrmCableTunnels ShowForm()
        {
            return FrmCableTunnels.ShowForm(true);
        }

        public static FrmCableTunnels ShowForm(bool Refresh)
        {
            string FormIdent = GenerateFormIdent();
            FrmCableTunnels frm = (FrmCableTunnels)FindForm(FormIdent);
            if (frm != null)
            {
                frm.Activate();
            }
            else
            {
                frm = new FrmCableTunnels();
                frm.ShowAsMDI(Program.MainForm);
            }
            if (Refresh)
                frm.RefreshForm();
            return frm;
        }

        public void RefreshForm()
        {
            cableTunnelList1.RefreshControl();
        }

        public void SetNearPoint(Coordinate coordinate, int coordinateTolerance)
        {
            cableTunnelList1.nearCoordinate = coordinate;
            cableTunnelList1.coordinateTolerance = coordinateTolerance;
            panelShowAll.Visible = true;
            RefreshForm();
        }

        private void btnShowAll_Click(object sender, EventArgs e)
        {
            panelShowAll.Visible = false;
            cableTunnelList1.nearCoordinate = null;
            RefreshForm();
        }

        private void cableTunnelList1_ViewRowIDChanged(object sender, Framework.BaseDetailCtl.ShowDetailEventArgs e)
        {
            cableFromCableTunnelList1.DetailID = e.DetailID;
        }
    }
}
